package zack.gateway.sdk.config;

import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
import zack.gateway.sdk.application.GatewaySDKApplication;
import zack.gateway.sdk.domain.service.GatewayCenterService;

/**
 * @author A1793
 */
@Configuration
@EnableConfigurationProperties({GatewaySDKProperties.class})
@ConditionalOnProperty(
        prefix = "api-gateway-sdk",
        name = "enable",
        havingValue = "true",
        matchIfMissing = true
)
public class GatewaySDKAutoConfig {

    @Bean
    public GatewayCenterService gatewayCenterService(){
        return new GatewayCenterService();
    }

    @Bean
    public GatewaySDKApplication gatewaySDKApplication(GatewaySDKProperties gatewaySDKProperties,GatewayCenterService gatewayCenterService){
        return new GatewaySDKApplication(gatewaySDKProperties,gatewayCenterService);
    }
}
